package com.gaga.console.core.controller.bv;


import com.gaga.common.path.ApiPath;
import com.gaga.common.result.Result;
import com.gaga.common.utils.ResourcesUtils;
import com.gaga.console.base.controller.BaseController;
import com.gaga.console.base.utils.VideoPlayerUtils;
import com.gaga.console.core.entity.dto.MainVideoStartDto;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.core.io.ResourceLoader;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.io.File;
import java.io.IOException;


/**
 * 用户信息表 前端控制器
 *
 * @author liujia
 * @since 2025-03-27
 */
@RestController
@RequestMapping(ApiPath.ROOT + "/bv/mainVideo")
public class MainVideoController extends BaseController {

    @Autowired
    private ResourceLoader resourceLoader;

    @ApiOperation(value = "createWindow")
    @PostMapping("/createWindow")
    public Result start(@RequestBody MainVideoStartDto mainVideoStartDto) throws IOException {

        File iconFile = ResourcesUtils.getResourceAsFile(resourceLoader, "static/icons/window-icon.png");

        //默认启动主视频里面的第一个
        VideoPlayerUtils.createWindow(
                mainVideoStartDto.getWidth(),
                mainVideoStartDto.getHeight(),
                mainVideoStartDto.getTitle(),
                mainVideoStartDto.getBgColor(), iconFile);

        return Result.ok();
    }

}
